﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>无标题页</title>
    <script type="text/javascript">
    function changeColor()
    {
        var tableLinks = document.getElementById("tableLinks");
        var trs = tableLinks.getElementsByTagName("tr");
        for(var i=0;i<trs.length;i++)
        {
            var tr = trs[i];
            if(i%2)
            {
                tr.style.background = "yellow";
            }
        }
    }
    </script>
</head>
<body>
<table id="tableLinks">
<tr><td>sadsa</td><td>100</td></tr>
<tr><td>sadsa</td><td>100</td></tr>
<tr><td>sadsa</td><td>100</td></tr>
<tr><td>sadsa</td><td>100</td></tr>
</table>
<br />
<input type="button" value="变色" onclick="changeColor()"/>
</body>
</html>
